<template>
  <div class="picking zy-content">
    <div class="searchBox search-box-layout">
      <Row :gutter="24">
        <Col span="4">
          <div>
            <p class="label">{{ $t('流程代码') }}</p>
            <div class="ipt">
              <Input v-model="processCode"
                     :placeholder="`${$t('common.inputInfo')}`"
              />
            </div>
          </div>
        </Col>
        <Col span="4">
          <div>
            <p class="label hide-label">--</p>
            <div class="ipt">
              <Button class="search-btn" type="primary" @click="searchList">
                {{ $t('common.Query') }}
              </Button>
              <Button
                class="reset-btn"
                @click="reset()"
              >{{ $t('common.reset') }}
              </Button>
            </div>
          </div>
        </Col>
      </Row>
    </div>
    <div class="list-layout mt16">
            <div class="btns clear">
              <span class="title">{{ $t('common.listInformation') }}</span>
                <Button @click="getTableColumns(columns)">
                    {{ handleContextMenuStatus ? $t('显示操作栏') : $t('隐藏操作栏') }}
                </Button>
            </div>
      <div class="tableContent">
        <Table  class="resizable-table" border @on-column-width-resize="onColumnWidthResize" :columns="columnsList" :data="dataList">
          <template slot-scope="{ row, index }" slot="action">
            <span class="operationBtn" @click="editClick(row)">{{$t('查看')}}</span>
          </template>
        </Table>
      </div>
      <div class="pageWrap">
        <Page :total="total"
              :page-size="pageSize"
              :page-size-opts="pageSizeOption"
              :current="pageNum"
              @on-change="changePageNum"
              @on-page-size-change="changePageSize"
              show-sizer show-total />
      </div>
    </div>
  </div>
</template>

<script>
import {queryProcessInfo} from "@/api/index.js";
import {mapGetters} from "vuex";
import toggleTableOperation from "@/mixins/toggleTableOperation";
export default {
  name: 'index',
    mixins:[toggleTableOperation],
  data() {
    return {
      pageNum:1,
      pageSize:10,
      total:0,
      pageSizeOption: [10,20,30,40],
      processCode:"",
      columns: [
        {
          title: `${ this.$t('流程代码') }`,
          key: 'processCode',
          align: 'center',
            resizable: true
          // minWidth: 120
        },
        {
          title: `${ this.$t('流程名称') }`,
          key: 'processName',
          align: 'center',
            resizable: true
          // minWidth: 120
        },
        {
          title: `${ this.$t('备注') }`,
          key: 'processRemark',
          align: 'center',
            resizable: true
          // minWidth: 120
        },
        {
          title: `${ this.$t('更新时间') }`,
          key: 'updateTime',
          align: 'center',
            resizable: true
          // minWidth: 120
        },
        {
          title: `${ this.$t('common.operation') }`,
          key: 'action',
          align: 'center',
          slot: 'action'
        }
      ],
      dataList: []
    }
  },
    created() {
      this.getTableColumnsWidth(this.columns)
    },
    mounted() {
        this.queryProcessInfo()
  },
  methods:{
    changePageSize(pageSize) {
      this.pageSize = pageSize;
      this.searchList();
    },
    reset(){
      this.processCode = '';
      this.searchList();
    },
    changePageNum(val){
      this.pageNum = val;
      this.searchList();
    },
    searchList(){
      this.queryProcessInfo()
    },
    editClick(row){
      this.$store.commit('detail/SET_PROCESS',row)
      this.$router.push('/ApprovalProcessdetail')
    },
    async queryProcessInfo(){
      this.dataList = []
      const obj = {
        pageNum:this.pageNum,
        pageSize:this.pageSize,
        processCode:this.processCode
      }
      const {data} = await queryProcessInfo(obj)
      if (data.list && data.list.length){
         this.dataList = data.list
        this.total = data.total
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.pageWrap{
  margin-top: 15px;
}
</style>
